package com.rogo.mini.component
{
	import com.rogo.mini.core.Metro;
	import com.rogo.mini.core.VisualElement;
	
	import flash.events.MouseEvent;

	/**
	 * HScrollBar Component
	 * 
	 * @author Rogo
	 */	
	public class HScrollBar extends VisualElement
	{
		public function HScrollBar()
		{
		}
		
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		private var thumb:Button;
		
		private var _contentWidth:Number;

		public function get contentWidth():Number
		{
			return _contentWidth;
		}

		public function set contentWidth(value:Number):void
		{
			if (_contentWidth != value)
			{
				_contentWidth = value;
				
				invalidateDisplayList();
			}
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		override protected function updateElement():void
		{
			super.updateElement();
			
			thumb = new Button();
			thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumb_mouseDownHandler);
			addElement(thumb);
		}
		
		override protected function updateDisplayList():void
		{
			super.updateDisplayList();
			
			// track
			graphics.beginFill(Metro.BLUE);
			graphics.drawRect(0, 0, width, height);
			graphics.endFill();
			
			// thumb
			if (isNaN(contentWidth))
				thumb.width = width;
			else
				thumb.width =  width / contentWidth * width;
			thumb.height = height;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Event Handlers
		//
		//--------------------------------------------------------------------------
		
		private function thumb_mouseDownHandler(e:MouseEvent):void
		{
		}
		
	}
}